function MessageBundle(bundle) {
   this.bundle = bundle;
   this.parameter = /%[0-9]+/g;
}

MessageBundle.prototype.format = function() {
   if (arguments.length==0) {
      throw "MessageBundle.format requires an id parameter";
   }
   var string = this.bundle.getString(arguments[0]);
   var rest = string.split(/%[0-9]+/);
   var result = "";
   for (var i=0; i<rest.length; i++) {
      result += rest[i];
      if (i<arguments.length) {
         result += arguments[i];
      }
   }
   return result;
   /*
   
   var match = null;
   var last = 0;
   var result = "";
   while ((match=this.parameter.exec(string))) {
      alert("Matched: "+match[0]);
      result = result+string.substring(0,match.index);
      result = result+arguments[parseInt(match[0].substring(1))];
      string = string.substring(match.index+match[0].length);
      alert("Rest: "+string);
   }
   result = result+string;
   result.replace(/\\n/,'\n');
   return result;
    */
}